package com.alibaba.mapper;


import com.alibaba.bean.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface NoteListMapper {

    @Select(value = "select forum.forumId,follow.fansId,forum.content,forum.likeNum,forum.replyNum from forum left join follow on forum.userId=follow.userId where follow.fansId=#{userId} limit #{notelow},#{notehigh}")
    List<DailyListData> noteFollow(@Param("userId") int userId, int notelow, int notehigh);

    @Select(value = "select forum.forumId,forum.content,forum.likeNum,forum.replyNum,forum.imgList from forum order by forum.forumId DESC limit #{notelow},#{notehigh}")
    List<DailyListData> noteNew(int notelow, int notehigh);

    @Select(value = "select f.imgList from forum f where f.forumId=#{forumId}")
    String img(int forumId);

    @Select(value = "select follow.followId,follow.userId,follow.fansId from follow left join forum on follow.userId=forum.userId where forum.forumId=#{forumId} and follow.fansId=#{userId} limit 0,1")
    CheckFollow checkFollow(int forumId, int userId);

    @Select(value = "select l.islikeId,l.userId,l.forumId from islike l where l.userId=#{userId} and l.forumId=#{forumId} limit 0,1")
    CheckLike checkLike(int userId, int forumId);

    @Select(value = "select user.username,user.avatar,user.userId from user left join forum on forum.userId=user.userId where forum.forumId=#{forumId}")
    AuthorInfo info(int forumId);

    @Select(value = "select replycontent.userId,user.username,replycontent.touserId,replycontent.content from replycontent left join user on user.userId=replycontent.userId where replycontent.forumId=#{forumId} and replycontent.touserId is not null limit #{notelow},#{notehigh}")
    List<ReplyListData> noteReply(int forumId, int notelow, int notehigh);

    @Select(value = "select u.username from user u where u.userId=#{touserId}")
    String rName(int touserId);

    @Select(value = "select user.username from user left join follow on user.userId=follow.followId left join forum on forum.userId=follow.followId left join replycontent on replycontent.touserId=forum.userId where follow.userId=#{userId} limit #{notelow},#{notehigh}")
    String[] toReplyName(@Param("userId") int userId, int notelow, int notehigh);

}
